#!/bin/bash
# 定义最大并发数量
MAX_CONCURRENT=2

# 计算当前正在执行该脚本的进程数量（不包括grep和awk命令本身）
CURRENT_PROCESSES=$(ps -ef | grep "run_without_java_new.sh" | grep -v "grep" | grep -v "awk" | wc -l)

# 如果当前进程数量大于等于最大并发数量，则等待
while [ $CURRENT_PROCESSES -ge $MAX_CONCURRENT ]
do
    echo "Current running processes: $CURRENT_PROCESSES, waiting for available slots...$3" > process-wait.log
    sleep 1
    CURRENT_PROCESSES=$(ps -ef | grep "run_without_java_new.sh" | grep -v "grep" | grep -v "awk" | wc -l)
done


cd /root/AKS/Project_Plot/
./run_without_java_new.sh $1 $2 $3 $4 $5    > /dev/null  2>&1 &